package util
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import mx.controls.Alert;
	
	public class FileReader
	{
		public var completeHandler:Function;
		
		public function FileReader()
		{
		}

		public function read(url:String):void
		{
			if (url != null && url != "") 
			{
				var request:URLRequest = new URLRequest(url);
	            
	            var loader:URLLoader = new URLLoader();
	            
	            loader.addEventListener(Event.COMPLETE, completeHandler);
	            
	            try
	            {
	                loader.load(request);
	            }
	            catch (error:ArgumentError)
	            {
	                Alert.show("sorry, there is an error with data loading!");
	            }
	            catch (error:SecurityError)
	            {
	                Alert.show("sorry, there is an error with data loading!");
	            }
            }
		}
	}
}